home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
utils
/
bigcolor.lzh
/
BIGCOLOR.S
< prev
Wrap
Text File
|
1990-02-06
|
45KB
|
2,046 lines
; BIGCOLOR.PRG V1.05
; JON DALTON
; DECEMBER 1989
MOVE.W #4,-(SP)
TRAP #14 ; Check MONO monitor attached
ADDQ.L #2,SP
CMP.W #2,D0 ; If not, then end program (NODO)
BEQ HIGH
NODO:
MOVE.L #MONO1,-(SP) ; Address of end message
MOVE.W #9,-(SP) ; Print message
TRAP #1
ADDQ.L #6,SP
MOVE.W #0,-(SP) ; End program and return to GEM desktop
TRAP #1
HIGH:
CLR.L -(SP) ; Go into Supervisor mode
MOVE.W #32,-(SP)
TRAP #1
ADDQ.L #6,SP
MOVE.L D0,SUPERVISOR ; Save the old stack pointer
;The next 16 lines check whether the program has already been run by
;checking memory location $3EC for 'magic number' $ABCCBA12. If
;it has been run, memory location $3F0 should contain start address
;of the program in high memory. If not, it reserves memory by changing
;$42E (PHYSTOP) and rebooting.
CMP.L #$abccba12,$3Ec
BNE DUMPIT
MOVE.L $42E,D0
CMP.L $3F0,D0
BLE ITSOK
MOVE.L $3F0,$42E
RESET
DUMPIT:
MOVE.L $42E,A0
CMP.L #$abccba12,(A0)
BEQ ITSOK
RESSET:
MOVE.L #$abccba12,$3Ec
SUB.L #$32000,$42E
MOVE.L $42E,$436
MOVE.L $42E,$3F0
RESET
ITSOK:
MOVE.L #$ABCCBA12,$3EC
MOVE.L #STARTUP,-(SP) ; Print STARTUP
MOVE.W #9,-(SP)
TRAP #1
ADDQ.L #6,SP
;Input the screen refresh rate
INPUTT:
MOVE.L #INPUT,-(SP)
MOVE.W #9,-(SP) ; Print message
TRAP #1
ADDQ.L #6,SP
MOVE.B #1,STORE
MOVE.L #STORE,-(SP)
MOVE.W #10,-(SP) ; Input the digit
TRAP #1
ADDQ.L #6,SP
TST.B STORE+1
BNE INPUTOK ; If return has been pressed, SPEED is set to 14
MOVE.L #AVERAGE,-(SP)
MOVE.W #9,-(SP) ; Print AVERAGE
TRAP #1
ADDQ.L #6,SP
MOVE.W #14,D0
BRA DEFAULT
INPUTOK:
MOVE.B STORE+2,D0
SUB.W #47,D0
BLE INPUTT ; Not a number or letter
CMP.W #10,D0
BGT NODO ; A letter has been entered, so exit the program
SUB.W #1,D0
MULU #4,D0 ; Multiply by 4 to get SPEED
TST D0
BNE DEFAULT
MOVE.W #50,D0 ; Zero entered, so set SPEED equal to 50
DEFAULT:
MOVE.W D0,SPEED
;The next 24 lines check whether the program is already installed in
;high memory, and activates it by setting up VBLANK, XBIOS MONITOR-
;CHANGED and ETVTERM VECTORS, the addresses of which are at the start of
;the program which is found from $3F0. It also sets up the new SPEED,
;and sets GEM desktop to colour.
MOVE.L $3F0.W,D0
MOVE.L D0,A0 ; Checks the program has been installed before
MOVE.L (A0),D0
CMP.L #$ABCCBA12,D0 ; 'Magic Number'
BNE INSTALL
MOVE.W SR,-(SP)
OR.W #$0700,SR ; Set interupt level to 7
ADDQ.L #4,A0
MOVE.L (A0)+,$0B8.W ; Sets up the new vectors
MOVE.L (A0)+,$070.W
MOVE.L (A0)+,$46E.W
MOVE.L (A0)+,$408.W
MOVE.L (A0)+,A0
MOVE.L SPEED,(A0) ; Set SPEED that has been entered
ADD.L #28,A0
MOVE.B #3,(A0)
MOVE.W (SP)+,SR
MOVE.W #37,-(SP)
TRAP #14
ADDQ.L #2,SP
MOVE.W #0,-(SP)
MOVE.L #-1,-(SP)
MOVE.L #-1,-(SP)
MOVE.W #5,-(SP) ; Set GEM DESKTOP to colour
TRAP #14
ADD.L #12,SP
BRA ENDPROG
;Program has not been installed before.
INSTALL:
MOVE.L #CALCULATE,-(SP)
MOVE.W #9,-(SP) ; Print message that it is installing.
TRAP #1
ADD.L #6,SP
;TABLE CALCULATION. The next 42 lines calculates a lookup table
;that converts a binary word %aaaaaaaabbbbbbbb into a binary word
;%babababababababa. It does this transformation on all possible
;words, starting at $0000 then $0001 etc up to $FFFE. $FFFF is added
;at the end. It is slow as it has to check every bit of every word.
MOVE.L #CODE,D0 ; Place the lookup table at this address
MOVE.L D0,TABLE ; $20000 bytes long
CLR.L D4
MOVE.W #0,D4
MOVE.L D0,A4
CLR.L D0
CLR.L D2
WORDLOOP:
CLR.L D6
CLR.L D5
CLR.L D3
MOVE #7,D5 ; Loop round 8 times for one byte (the low byte)
MOVE #1,D3 ; D3 is a mask which moves up the byte
MOVE.L D3,D1 ; D1 contains the position of the mask temporarily
MOVE.L D4,D0 ; D4 contains the word which is being transformed
BITLOOP:
AND.L D0,D1 ; D0 contains the word temporarily
MULU D1,D1 ; Move the bit to its new location, if it was set
ADD.L D1,D2 ; D2 has the transformed set bits added to it
ADD D3,D3 ; Shift the mask left one bit
MOVE.L D3,D1
DBF D5,BITLOOP ; Loop round 8 times
TST.L D6 ; D6 is set when the high byte has been dealt with
BNE MOREDO1:
LSR.L #8,D0 ; Move the high byte to the low byte
LSL.L #1,D2 ; Offset the bits that have already been calculated
CLR.L D3
CLR.L D1
MOVE #1,D3 ; Reset the mask (D3) to #1
MOVE D3,D1
MOVE.L #1,D6 ; Set D6 to indicate high byte is being dealt with
MOVE.L #7,D5
BRA BITLOOP ; Repeat the process (high byte is now low byte)
MOREDO1:
CLR.L D6 ; Clear D6 ready to start a new word
MOVE.W D2,(A4)+ ; Save the completed transformed word in the table
CLR.L D2
ADDQ #1,D4 ; Add #1 to get the next word to transform
CMP #$FFFF,D4 ; Check whether all the words have been done
BEQ FINISH
BRA WORDLOOP ; Loop back to calculate the next word
FINISH:
MOVE.W #$FFFF,(A4)+ ; The last entry in the table
;Set up the extra screen needed for monochrome, and the check screen.
;Place the screens after the table, making sure they lie on a 256-byte
;boundary.
MOVE.L A4,D0 ; A4 is the address after the table
ADD.L #$100,D0
AND.L #$FFFFFF00,D0 ; Make sure that last byte is zero (for screen)
MOVE.L D0,MONO ; Set MONO screen (which is actually displayed)
ADD.L #$8000,D0 ; COLOURCHECK screen to detect changes in COL screen
MOVE.L D0,COLOURCHECK
;Work out OFFSET for where the program is to be moved to in high memory
MOVE.L $3F0,D1
SUB.L #MONITOR,D1
ADD.L #512,D1
AND.L #$FFFFFE00,D1
MOVE.L D1,OFFSET
ADD.L D1,MONO
ADD.L D1,TABLE
ADD.L D1,COLOURCHECK
;Clear the new screens
MOVE.L COLOURCHECK,A4
MOVE.L MONO,A5
CLR.L D1
CLR.L D0
MOVE.W #7999,D1
LOADIT:
MOVE.L D0,(A4)+ ; Loads the table with zero to start
MOVE.L D0,(A5)+
DBF D1,LOADIT
MOVE.L $44E.W,COL ; Set up COL address (colour screen)
;Move the actual display to MONO address and set up SCRNCHK (to detect if
;the displayed screen address has been changed)
MOVE.L MONO,D0
LSR.L #8,D0
MOVE.L #$FF8200,A5
MOVEP.W D0,1(A5)
MOVE.L (A5),SCRNCHK
CLR.L D0
;Put the VECTOR addresses in the new code (replacing DUMMY) and set
;up the other variables.
MOVE.L $B8.W,VECTOR1+2
MOVE.L $70.W,VECTOR2+2
MOVE.L $70.W,VECTOR2A+2
MOVE.L $408.W,VECTOR3+2
MOVE.L $70.W,VBLADD
MOVE.L #0,POSITION ; Set the position to the top
MOVE.L #199,COUNTER ; Set counter to count down from 200 (DBF loop)
MOVE.B #0,COLOR ; Set COLOR to #0 (Low Resolution)
MOVE.L #VBLANK,NEWVBL
;Set up the new MONITOR CHANGED vector and set up GEM DESKTOP to colour
MOVE.L #MONITOR,$46E
MOVE.W #0,-(SP)
MOVE.L #-1,-(SP)
MOVE.L #-1,-(SP)
MOVE.W #5,-(SP)
TRAP #14
ADD.L #12,SP
;Move the program to high memory. Offset has already been calculated,
;various addresses need to be relocated so they have D6 added to them.
MOVE.L #MONITOR,A3 ; MONITOR is the start address to relocate
MOVE.L A3,A4
ADD.L OFFSET,A4
MOVE.L OFFSET,D6
ADD.L D6,REL1+2 ; Add the offset to variables
ADD.L D6,REL2+2
ADD.L D6,REL3+2
ADD.L D6,REL4+2
ADD.L D6,REL5+2
ADD.L D6,REL6+2
ADD.L D6,REL7+2
ADD.L D6,REL8+2
ADD.L D6,REL9+2
ADD.L D6,REL10+2
ADD.L D6,REL11+2
ADD.L D6,REL12+2
ADD.L D6,REL14+2
ADD.L D6,REL15+2
ADD.L D6,REL16+2
ADD.L D6,REL17+6
ADD.L D6,REL18+6
ADD.L D6,REL20+2
ADD.L D6,REL21+2
ADD.L D6,REL22+2
ADD.L D6,REL34+2
ADD.L D6,REL35+2
ADD.L D6,REL40+2
ADD.L D6,REL41+2
ADD.L D6,REL73+2
ADD.L D6,REL74